public class Test {
    public static int lastlon(String s) {
        int count=0;
        int last=s.length()-1;
        while(s.charAt(last)!=' ' && s.charAt(last)!='\0') {
            count++;
            last--;
        }
        return count;
    }
    public static void main(String[] args) {
//        StringBuffer stringBuffer = new StringBuffer("heelo");
//        stringBuffer.append("fuck you");
//        System.out.println(stringBuffer);
        String str="XSUWHQ";
        System.out.println(lastlon(str));
    }
}
